<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加房产信息</title>
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<style type="text/css">
<!--
.STYLE1 {
	font-size: 12px
}

.STYLE3 {
	color: #707070;
	font-size: 12px;
}

.STYLE5 {
	color: #0a6e0c;
	font-size: 12px;
}

body {
	margin-top: 0px;
	margin-bottom: 0px;
}

.STYLE7 {
	font-size: 12
}
-->
</style>
<script language="javascript">
	function checkForm() {		
		var houseId = document.forms[0].houseId.value;
		var houseName = document.forms[0].name.value;
		var houseTypeId = document.forms[0].houseTypeId.value;
		var houseSourceId = document.forms[0].houseSourceId.value;
		var unit = document.forms[0].unit.value;
		var floor = document.forms[0].floor.value;
		var subId = document.forms[0].subId.value;
		var buildingId = document.forms[0].buildingId.value;
		var districtId = document.forms[0].districtId.value;
		
		if (houseId == null || houseId == "") {
			alert("请输入房产编号！");
			return false;
		} else if (houseId.length!=4) {
			alert("请输入4位小区编号！");
			return false;
		}
		if (houseName==null || houseName == "") {
			alert("请输入房产名称！");
			return false;
		}
		if (houseTypeId == 0) {
			alert("请选择房产类型！");
			return false;
		}
		if (houseSourceId == 0) {
			alert("请选择房产来源！");
			return false;
		}
		if (unit == 0) {
			alert("请输入房产所在单元！");
			return false;
		}
		if (floor == 0) {
			alert("请输入楼栋层数！");
			return false;
		}
		if(districtId == 0) {
			alert("请选择物业服务处！");
			return false;
		}
		if (subId == 0) {
			alert("请选择所属小区！");
			return false;
		}
		if (buildingId == 0) {
			alert("请选择所属楼栋！");
			return false;
		}		
		return true;
	}
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据小区ID查询DropChangeAJAXAction，获得该小区的楼栋列表
	function changeDropOfBuilding() {
		init();
		
		var url="dropChangeAJAX.do?method=changeDropOfBuilding&subId="+escape(document.forms[0].subId.options[document.forms[0].subId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	
	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				eval(req.responseText);
			}
		}
	}
</script>
</head>

<body>
<html:form action="house.do?method=save" method="post" onsubmit="return checkForm();" >
	<table align="center" cellspacing="1" cellpadding="0" width="80%" border="0">
		<tr>
			<td class="STYLE4" align="center" bgcolor="#ffffff" colspan="2"
				height="40">添加房产信息</td>
		</tr>
		<tr>
		<td>
		<table align="center" class="tableline" cellspacing="1" cellpadding="0" width="100%" border="0">
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">房产编号：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="houseId" style="width:155px;" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入4位数字，例如0001</span>
			 <font color="red">${houseIdError}</font> 
			</td>
		</tr>
		<tr>
			<td height="26" align="right" bgcolor="#ffffff">房产名称：</td>
			<td bgcolor="#ffffff">
			&nbsp;<html:text property="name"  style="width:155px;"/>
				 <font color="red">${houseNameError }</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">房产类型：</td>
			<td width="773" bgcolor="#ffffff">&nbsp;<html:select property="houseTypeId" style="width:159px;">
				<html:option value="0">请选择</html:option>
				<c:if test="${!empty houseTypeList}">
					<c:forEach items="${houseTypeList}" var="houseType">
						<html:option value="${houseType.id}">${houseType.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select><font color="red">${houseTypeError }</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">房产来源：</td>
			<td width="773" bgcolor="#ffffff">
				&nbsp;<html:select property="houseSourceId" style="width:159px">
				<html:option value="0">请选择</html:option>
				<c:if test="${!empty houseSourceList}">
					<c:forEach items="${houseSourceList}" var="houseSource">
						<html:option value="${houseSource.id}">${houseSource.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select>&nbsp;<font color="red">${houseSourceError }</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">房产面积：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="area" style="width:155px"/>
			<font color="red">${houseAreaError}</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">所在单元：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="unit" style="width:155px"/>&nbsp;&nbsp;<span style="color:#5f9c12;">请输入1位数字</span>
			 <font color="red">${houseUnitError}</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">所在楼层：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="floor" style="width:155px"/>
			 <font color="red">${houseFloorError}</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">物业服务处：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:select property="districtId"  style="width:159px">
					<html:option value="0">请选择</html:option>
					<c:if test="${!empty districtList}">
						<c:forEach items="${districtList}" var="district">
							<html:option value="${district.id}">${district.name}</html:option>
						</c:forEach>
					</c:if>
				</html:select>&nbsp;<font color = "red">${districtIdError }</font>
			</td>
		</tr>
		<tr>
		<td width="217" height="26" align="right" bgcolor="#ffffff">所属小区：</td>
		<td width="773" bgcolor="#ffffff">
			&nbsp;<html:select property="subId"  style="width:159px" onchange="changeDropOfBuilding()">
				<html:option value="0">请选择</html:option>
				<c:if test="${!empty subList}">
					<c:forEach items="${subList}" var="sub">
						<html:option value="${sub.id}">${sub.name}</html:option>
					</c:forEach>
				</c:if>
			</html:select>&nbsp;
			<font color = "red">${houseSubIdError }</font>
		</td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">所属楼栋：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:select property="buildingId" style="width:159px">
					<html:option value="0">请选择</html:option>
				</html:select>
				<font color = "red">${houseBuildingIdError}</font>
			</td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">业主姓名：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="ownerName" style="width:155px"/> 
			<font color="red">${houseOwnerNameError}</font></td>
		</tr>	
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">工作单位：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="workUnit" style="width:155px"/> </td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">联系电话：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="phone" style="width:155px"/> </td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">身份证：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="idCard" style="width:155px"/> 
			<font color="red">${houseOwnerCardIdError}</font></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">家庭成员姓名：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="fmName" style="width:155px"/></td>
		</tr>
		<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">家庭成员联系电话：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="fmPhone" style="width:155px"/> </td>
		</tr>
						<tr>
			<td width="217" height="26" align="right" bgcolor="#ffffff">家庭成员身份证：</td>
			<td width="773" bgcolor="#ffffff">
			&nbsp;<html:text property="fmIdCard" style="width:155px"/> </td>
		</tr>
		<tr>
			<td height="26" bgcolor="#ffffff" colspan="2">
				<div id="btnSubmit" style="padding-left:200px;"><html:submit value="添加房产及业主信息" />&nbsp;&nbsp;<html:reset value="清空房产及业主信息" /></div>
			</td>
		</tr></table></td></tr>		
	</table>
</html:form>
</body>
</html>